/**
 *    Copyright 2009-2019 the original author or authors.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.apache.ibatis.plugin;

import java.util.Properties;

/**
 * Mybatis 拦截器(插件)接口定义
 *
 * @author Clinton Begin
 */
public interface Interceptor {
    /**
     * 提供被拦截方法的代理实现，完成额外的业务处理
     *
     * @param invocation 代理
     */
    Object intercept(Invocation invocation) throws Throwable;

    /**
     * 该方法用于处理被拦截对象，返回该对象本身或者为其生成一个代理对象。
     * <p>
     * 如果返回的是代理对象，我们可以为指定方法实现代理实现:{@link #intercept(Invocation)}
     *
     * @param target 被拦截的对象
     */
    Object plugin(Object target);

    /**
     * 配置该插件运行时依赖的属性
     */
    void setProperties(Properties properties);

}
